<template>
    <el-form :model="form" :rules="rules" ref="form" label-width="100%">
        <el-form-item label="名称" prop="name">
            <el-input v-model="form.name" />
        </el-form-item>
        <el-form-item>
            <el-button type="primary" @click="submitForm('form')">立即创建</el-button>
            <el-button @click="resetForm('form')">重置</el-button>
        </el-form-item>
    </el-form>
</template>

<script>
export default {
    data(){
        return {
            form: {
                id: 0,
                name: "",
                pid: 0,
                rule: "",
                component: "",
                icon: "",
                is_menu: 0,
                status: 0,
                sequence: 99,
                remark: "",
            },
            rules: {

            }
        }
    },
    methods:{
        submitForm(formName) {
            this.$refs[formName].validate((valid) => {
                if (valid) {
                    alert('submit!');
                } else {
                    console.log('error submit!!');
                    return false;
                }
            });
        },
        resetForm(formName) {
            this.$refs[formName].resetFields();
        }
    }
}

</script>